package cn.wolfcode.mp.test;


import cn.wolfcode.mp.domain.Employee;
import cn.wolfcode.mp.mapper.EmployeeMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class SelectTestQuery {

    @Autowired
    private EmployeeMapper employeeMapper;

    //需求：查询所有员工， 返回员工name， age列
    @Test
    public void testQuery4(){

        QueryWrapper<Employee> wrapper = new QueryWrapper<>();

        wrapper.select("name","age");
        //wrapper.select("name,age");

        employeeMapper.selectList(wrapper);

    }

    //需求：查询所有员工， 返回员工以a字母开头的列
    @Test
    public void testQuery5(){

        QueryWrapper<Employee> wrapper = new QueryWrapper<>();

        // 第一个参数为 操作模型类的字节码对象
        // 第二个参数为创建一个对象，调用getProperty()方法获取列名，列名以a开头
        wrapper.select(Employee.class, tableFieldInfo->tableFieldInfo.getProperty().startsWith("a"));

        employeeMapper.selectList(wrapper);

    }

}